package com.zbs.simbot.plugins.genshin.plugins;

import cn.hutool.core.util.IdUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.zbs.simbot.annotations.Func;
import com.zbs.simbot.factory.abstracts.AbstractsBasePlugin;
import com.zbs.simbot.factory.dto.PluginInfo;
import com.zbs.simbot.enums.MsgType;
import com.zbs.simbot.events.BaseMsgEvent;
import com.zbs.simbot.plugins.genshin.service.MysUserService;
import com.zbs.simbot.plugins.genshin.service.impl.MysUserServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class MysUserPlugin extends AbstractsBasePlugin {

    @Override
    public String getId() {
        return IdUtil.getSnowflakeNextIdStr();
    }

    @Func(reg = "^#绑定(uid|UID)?[1-9][0-9]{8}$",msgType = MsgType.ALL)
    public void bingUid(BaseMsgEvent event) {
        MysUserService mysUserService = SpringUtil.getBean(MysUserService.class);
        mysUserService.bingUid(event);
    }

    @Func(reg = "^#(我的)?(uid|UID)[0-9]{0,2}$",msgType = MsgType.ALL)
    public void showUid(BaseMsgEvent event) {
        MysUserService mysUserService = SpringUtil.getBean(MysUserService.class);
        mysUserService.showUid(event);
    }

    @Func(reg = "^#?(米哈?游社?登录|登录米哈?游社?)$",msgType = MsgType.ALL)
    public void miHoYoLoginQRCode(BaseMsgEvent event) {
        if (event.getMsgType().equals(MsgType.GROUP)) {
            event.reply("请私聊发送");
            return;
        }
        MysUserService mysUserService = SpringUtil.getBean(MysUserService.class);
        mysUserService.mhyLoginQrCode(event);
    }

    @Override
    public PluginInfo getInfo() {
        return new PluginInfo("用户绑定","米游社ck绑定，游戏uid绑定");
    }
}
